<?php
class IndexAction extends CommonAction {
	// 框架首页
	public function index() {
		ob_clean();
		$this->_checkUser();
		$this->_Config_name();//调用参数
		C ( 'SHOW_RUN_TIME', false ); // 运行时间显示
		C ( 'SHOW_PAGE_TRACE', false );
		$fck = D ('Fck');
		
		$fck -> mr_fenhong(1);
		
		$id = $_SESSION[C('USER_AUTH_KEY')];
		$field = '*';
		$fck_rs = $fck -> field($field) -> find($id);

		$HYJJ="";
		$this->_levelConfirm($HYJJ,1);
		$this->assign('voo',$HYJJ);//会员级别

		$this->assign('fck_rs',$fck_rs);

		$fck->emptyMonthTime();
		//$fck->getLevel();

		$ydate = strtotime(date('Y-m-d'));//当天时间
		$end_date =$ydate + (24*3600);//当天结束时间

		$fee_rs = M('fee')->field('s2,i4,str29,str3')->find();
		$fee_i4 = $fee_rs['i4'];
		$gg = $fee_rs['str29'];
		$str3 = $fee_rs['str3'];//后台设置网站人数
		//网站人数设计----后台设置人数+实际人数
		$countnums=$fck->count();
		$wznums=$countnums+$str3;
		
		
		$this -> assign('gg',$gg);
		$this -> assign('wznums',$wznums);
		$this -> assign('fee_i4',$fee_i4);
		
		$map = array();
		$map['s_uid']   = $id;   //会员ID
		$map['s_read'] = 0;     // 0 为未读
        $info_count = M ('msg') -> where($map) -> count(); //总记录数
		$this -> assign('info_count',$info_count);
		
		//拿取冻结部分的管理金额
		$fck->jiedongjine();
		
		
//		//二维码调用
//		$erimg=$this->cserweima($fck_rs['id']);
//		$this -> assign('erimg',$erimg);	

		$arss = $this->_cheakPrem();
        $this->assign('arss',$arss);
        
        $Guzhi = A("Guzhi");
        $Guzhi->stock_past_due();
		
		
		
        
		//$fck -> mr_fenhong(1);
//		$this->aotu_clearings();
		
		$this->display('index');
	}

    //每日自动结算
	public function aotu_clearings(){
		$fck = D ('Fck');
		$fee = M ('fee');
		$nowday = strtotime(date('Y-m-d'));
		$nowweek = date("w");
		if($nowweek==0){
			$nowweek = 7;
		}
		$kou_w = $nowweek-1;
		$weekday = $nowday-$kou_w*24*3600;
		
		$now_dtime = strtotime(date("Y-m-d"));
		if(empty($_SESSION['auto_cl_ok'])||$_SESSION['auto_cl_ok']!=$now_dtime){
			$js_c = $fee->where('id=1 and f_time<'.$weekday)->count();
			if($js_c>0){
				//经理分红
				//$fck->jl_fenghong();
			}
			$_SESSION['auto_cl_ok'] = $now_dtime;
		}
		unset($fck,$fee);
	}
	
	public function cserweima($id){
		include './Public/phpqrcode/phpqrcode.php';
		$dizhi='http://www.aixincd.com/index.php/Reg/us_reg/rid/'.$id;
		//$dizhi='http://www.baidu.com';    
		//$value = 'http://www.cnblogs.com/txw1958/'; //二维码内容  
		$value=$dizhi; 
		$errorCorrectionLevel = 'L';//容错级别   
		$matrixPointSize = 6;//生成图片大小   
		//生成二维码图片   
		QRcode::png($value, 'qrcode'.$id.'.png', $errorCorrectionLevel, $matrixPointSize, 2);   
		$logo = 'logo.png';//准备好的logo图片   
		$QR = 'qrcode'.$id.'.png';//已经生成的原始二维码图   
		
		if ($logo !== FALSE) {   
			$QR = imagecreatefromstring(file_get_contents($QR));   
			$logo = imagecreatefromstring(file_get_contents($logo));   
			$QR_width = imagesx($QR);//二维码图片宽度   
			$QR_height = imagesy($QR);//二维码图片高度   
			$logo_width = imagesx($logo);//logo图片宽度   
			$logo_height = imagesy($logo);//logo图片高度   
			$logo_qr_width = $QR_width / 5;   
			$scale = $logo_width/$logo_qr_width;   
			$logo_qr_height = $logo_height/$scale;   
			$from_width = ($QR_width - $logo_qr_width) / 2;   
			//重新组合图片并调整大小   
			imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,   
			$logo_qr_height, $logo_width, $logo_height);   
		}   
		//输出图片   
		imagepng($QR, 'helloweixin'.$id.'.png');   
		//echo '<img src="helloweixin.png">';
		$img_reweima='helloweixin'.$id.'.png';
		return($img_reweima);
	}

}
?>